package com.dyh.quickdemozwei.avgDemo;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class AvgScene {
    public List<AvgCommand> avgCommands;
    public AvgScenario avgScenario;
    public AvgEngine avgEngine;

    public void execute(){
        List<AvgCommand> sortedCommandList =
                avgCommands.stream().sorted(Comparator.comparing(e->-e.speed))
                        .collect(Collectors.toList());


        for (AvgCommand command : sortedCommandList) {
            int res = command.execute(avgScenario,avgEngine);
            if (res>0){
                break;
            }
        }
    }
}
